{% load i18n highlight pagination_tags %}
<!-- BEGIN search results -->
<div class="module" id='search_module'>
  <div class="module-wrapper">

    <div class="module-header">
      <h3 id="id_search_title">{% if query %}{% blocktrans %}{{ count }} Results for {{ query }}{% endblocktrans %}{% else %}{% trans "No search term entered" %}{% endif %}</h3>
      {{ form.errors.as_ul }}
    </div>

     <!-- Begin faceting. -->
     {% if query %}
      {% if selected_facets_list %}
        {# Translators: The refers to filtering a search by using facets #}
        <h5>{% trans "Filtered by" %}
          {% for facet in selected_facets_list %}
            <strong>{{ facet.1 }}</strong>{% if not forloop.last %}, {% endif %}
          {% endfor %} <small>(<a href="?q={{ query }}" id='id_remove_facets'>{% trans "remove" %}</a>)</small></h5>

      {% else %}
      <h5>{% trans "Filter by Project" %}</h5>
      <div class="filter">
          <dl>
              {% if facets.fields.project %}
                  {# Provide only the top N projects #}
                  {% for project in facets.fields.project|slice:":10" %}
                      {% if project.1 != 0 %}
                      <dd><a href="?q={{ query }}&amp;selected_facets=project_exact:{{ project.0|urlencode }}">{{ project.0 }}</a> <small>({{ project.1 }})</small></dd>
                      {% endif %}
                  {% endfor %}
              {% else %}
                  <p>{% trans "No project facets." %}</p>
              {% endif %}
          </dl>
      </div>
      {% endif %}
    {% endif %}
    <!-- End faceting -->

    <div class="module-list">
      <div class="module-list-wrapper">
        <ul id="id_search_result">
        {% if query %}
           {% autopaginate results 10 %}
           {% for result in results %}
            <li class="module-item">
            {% ifequal result.model_name 'project' %}
              <p class="module-item-title">
                {% trans "Project:" %}
                <a href="{% if result.absolute_url %}{{ result.absolute_url }}{% else %}{{ result.object.get_absolute_url }}{% endif %}">{{ result.title }} - {{ result.author }}</a>
              </p>
              {% else %}
              <p class="module-item-title">
                {% trans "File" %}
                <a href="{% if result.absolute_url %}{{ result.absolute_url }}{% else %}{{ result.object.get_absolute_url }}{% endif %}?highlight={{ query }}">{{ result.project }} {% if result.version %} ({{ result.version }}) {% endif %} - {{ result.title }}</a>
              </p>
              <p>
                {% highlight result.text with query %}
              </p>
              {% endifequal %}
            </li>
          {% empty %}
            <li class="module-item"><span class="quiet">{% trans "No results found. Bummer." %}</span></li>
          {% endfor %}
        {% endif %}
        </ul>
      </div>
    </div>

  {% paginate %}

  </div>
</div>

<!-- END search results -->
